CC = gcc
LFLAGS = -g -W -Wall -Werror -Wmissing-declarations -Wmissing-prototypes -Wredundant-decls -Wshadow -Wbad-function-cast -Wcast-qual -o
CFLAGS = -c -g -W -Wall -Werror -Wmissing-declarations -Wmissing-prototypes -Wredundant-decls -Wshadow -Wbad-function-cast -Wcast-qual
EXEC = ping traceroute
SRCP = $(subst traceroute.c,,$(wildcard *.c))
SRCT = $(subst ping.c,,$(wildcard *.c))
OBJP = $(SRCP:.c=.o)
OBJT = $(SRCT:.c=.o)

all : $(EXEC)

ping : $(OBJP)
	@ $(CC) $(LFLAGS) $@ $^ $(LDFLAGS)
%.o :%.c
	@ $(CC) $(CFLAGS) $< -o  $(subst traceroute,,$*).o

traceroute : $(OBJT)
	@ $(CC) $(LFLAGS) $@ $^ $(LDFLAGS)
%.o : %.c
	@ $(CC) $(CFLAGS) $< -o $(subst ping^_,,$*).o

clean:
	@ rm -f $(OBJ)
mrproper: clean
	@ rm -f $(EXEC)
